<?php

namespace App\Http\Controllers\admin\defaults;

use App\Http\Controllers\admin\defaults\BaseController;
use App\Helpers\commonFuc;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;

class ConfigController extends BaseController
{
    private $tpviewhead='admin.defaults.config.';
    private $table='config';
    function __construct(Request $thisRequest)
    {
        parent::__construct($thisRequest,$this->tpviewhead,$this->table);
    }


    function lists()
    {
        //条件输入
        $keyname=$this->thisRequest->get('keyname');
        $title=$this->thisRequest->get('title');
        $value=$this->thisRequest->get('value');
        $id=$this->thisRequest->get('id');
        $data = $this->thisModel;
        //条件
        if($keyname){
            $data =$data->where('keyname', 'like', '%'.$keyname.'%');
        }
        if($title){
            $data =$data->where('title', 'like', '%'.$title.'%');
        }
        if($value){
            $data =$data->where('value', 'like', '%'.$value.'%');
        }
        if($id){
            $data =$data->where('id', $id);
        }

        $limit = (int)$this->thisRequest->get('limit');
        $limit = $limit ? $limit : 15;
        $data = $data->where('isshow',1)->paginate($limit);
        if($this->thisRequest->ajax()){
            return commonFuc::data_reture_json($data,200,'');
        }

        return view($this->tpviewhead . 'lists',['data'=>$data]);
    }



}